package com.study.user;

import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.CallSuper;
import com.common.base.fragment.BaseThemeFragment;
import com.common.bean.InfoResult;
import com.common.ui.barlibrary.ImmersionBar;
import com.common.ui.circleimageview.CircleImageView;
import com.common.utils.AntiShake;
import com.common.utils.GlideUtils;
import com.study.R;
import butterknife.BindView;
import butterknife.OnClick;

public class UserFragment extends BaseThemeFragment {

    @BindView(R.id.background)
    LinearLayout background;
    @BindView(R.id.linear_theme)
    LinearLayout linearTheme;
    @BindView(R.id.iv_head_image)
    CircleImageView ivHeadImage;
    @BindView(R.id.linear_beautiful)
    LinearLayout linearBeautiful;
    @BindView(R.id.linear_help)
    LinearLayout linearHelp;
    @BindView(R.id.linear_recommendation)
    LinearLayout linearRecommendation;
    @BindView(R.id.linear_advice)
    LinearLayout linearAdvice;
    @BindView(R.id.linear_vip)
    LinearLayout linearVip;
    @BindView(R.id.linear_notice)
    LinearLayout linearNotice;
    private GlideUtils glideUtils;

    //todo
    private String path = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1598071802723&di=be50f2c27b511a407edb27cbce385072&imgtype=0&src=http%3A%2F%2Fpic.nen.com.cn%2F0%2F12%2F12%2F28%2F12122876_637955.jpg";

    @Override
    public boolean isImmersionBarEnabled() {
        return true;
    }

    @Override
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this)
                .fitsSystemWindows(false)
                .init();
    }

    @CallSuper
    @Override
    public void updateUiElements() {
        super.updateUiElements();

    }

    @Override
    public View isSupportLoadSirEnabled() {
        return null;
    }

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_user;
    }

    @Override
    public void init() {
        glideUtils = GlideUtils.getInstance();
        glideUtils.loadHeadImageView(getActivity(), path, ivHeadImage);
    }

    @Override
    public void loadData() {

    }

    @OnClick({R.id.linear_theme, R.id.iv_head_image, R.id.linear_vip, R.id.linear_notice,
            R.id.linear_beautiful, R.id.linear_help,R.id.linear_recommendation, R.id.linear_advice})
    public void OnClick(View view) {
        switch (view.getId()) {
            //会员
            case R.id.linear_vip:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), UseVipActivity.class, false);
                break;
            //系统公告
            case R.id.linear_notice:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), SystemAnnouncementsActivity.class, false);
                break;
            //海报背景和显示设置
            case R.id.linear_beautiful:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), BeautifulActivity.class, false);
                break;
            //主题
            case R.id.linear_theme:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), SetActivity.class, false);
                break;
            //帮助
            case R.id.linear_help:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), HelpActivity.class, false);
                break;

            //推荐
            case R.id.linear_recommendation:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), RecommendationActivity.class, false);
                break;
            //建议反馈
            case R.id.linear_advice:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), AdviceActivity.class, false);
                break;
            case R.id.iv_head_image:
                //判断是否多次点击
                if (AntiShake.check(view.getId())) {
                    return;
                }
                switchTo(getActivity(), UserDetailsActivity.class, false);
                break;
            default:
                break;
        }
    }

    @Override
    protected void onSuccess(int what, InfoResult t) {

    }

    @Override
    protected void onFail(int what, InfoResult t) {

    }
}
